package com.cyberypower.sjs.socket2jabber;

import com.cyberypower.sjs.common.Config;
import com.cyberypower.sjs.common.ConfigLoader;
import com.cyberypower.sjs.common.Log;
import com.cyberypower.sjs.jabber.JabberAddress;

public class Socket2Jabber {


    private int portToListen;
    private JabberAddress s2jAddress;
    private JabberAddress j2sAddress;

    public Socket2Jabber(JabberAddress s2jAddress, JabberAddress j2sAddress, int portToListen) {
        this.portToListen = portToListen;
        this.s2jAddress = s2jAddress;
        this.j2sAddress = j2sAddress;
    }

    private void emph() {
        MultiSocketServer multiSocketServer = new MultiSocketServer(s2jAddress, j2sAddress, portToListen);
        try {
            multiSocketServer.emph();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        Log.init();
        if (args.length < 1) {
            System.out.println("Obligatory option : properties_file");
            System.exit(1);
        }
        ConfigLoader.loadPropertiesS2J(args[0]);
        Socket2Jabber m = new Socket2Jabber(Config.ADDRESS_S2J, Config.ADDRESS_J2S, Config.S2J_PORT);
        m.emph();
    }
}
